﻿$(function () {
    var events = [
      {
          title: 'All Day Event',
          start: '2015-02-01'
      },
      {
          title: 'Long Event',
          start: '2015-02-07',
          end: '2015-02-10'
      },
      {
          id: 999,
          title: 'Repeating Event',
          start: '2015-02-09T16:00:00'
      },
      {
          id: 999,
          title: 'Repeating Event',
          start: '2015-02-16T16:00:00'
      },
      {
          title: 'Conference',
          start: '2015-02-11',
          end: '2015-02-13'
      },
      {
          title: 'Meeting',
          start: '2015-02-12T10:30:00',
          end: '2015-02-12T12:30:00'
      },
      {
          title: 'Lunch',
          start: '2015-02-12T12:00:00'
      },
      {
          title: 'Meeting',
          start: '2015-02-12T14:30:00'
      },
      {
          title: 'Happy Hour',
          start: '2015-02-12T17:30:00'
      },
      {
          title: 'Dinner',
          start: '2015-02-12T20:00:00'
      },
      {
          title: 'Birthday Party',
          start: '2015-02-13T07:00:00'
      },
      {
          title: 'Click for Google',
          url: 'http://google.com/',
          start: '2015-02-28'
      }
    ];

    $('#fccalendar').fullCalendar({
        header: {
            left: 'prevYear,prev,next,nextYear, today',
            center: 'title',
            right: 'month,basicWeek'
        },
        events: function (start, end, timezone, callback) {
            $.ajax({
                url: '/task/GetTasksByUser',
                dataType: 'json',
                data: {
                    // our hypothetical feed requires UNIX timestamps
                    start: start.unix(),
                    end: end.unix(),
                    userid: 0
                },
                success: function (doc) {
                    var events = [];
                    $(doc).find('event').each(function () {
                        events.push({
                            title: $(this).attr('title'),
                            start: $(this).attr('start') // will be parsed
                        });
                    });
                    callback(events);
                }
            });
        },
        editable: true,
        eventLimit: true// allow "more" link when too many events

    });


    //右侧切换
    $("#righttoggle").click(function () {
        if ($(this).find("i").hasClass("icon-step-forward")) {
            $(".layout_content_sidebar").hide();
            $(this).find("i").removeClass("icon-step-forward").addClass("icon-step-backward");
            $(".g-main .layout_content_main").css("margin-right", "0");
        } else {
            $(".layout_content_sidebar").show();
            $(this).find("i").removeClass("icon-step-backward").addClass("icon-step-forward");
            $(".g-main .layout_content_main").css("margin-right", "240px");
        }
    });

    $(".layout_content_sidebar_footer").click(function () {
        if ($(this).find("i").hasClass("icon-eye-open")) {
            $(this).find("i").removeClass("icon-eye-open").addClass("icon-eye-close");
            $(this).find("span").html("显示全部日程");
        } else {
            $(this).find("i").removeClass("icon-eye-close").addClass("icon-eye-open");
            $(this).find("span").html("只显示我的日程");
        }
    });

    //$(".layout_content_sidebar_header li").click(function () {
    //    $(".layout_content_sidebar_header li").removeClass("active");
    //    $(this).addClass("active");
    //    var ind = $(".layout_content_sidebar_header li").index($(this));
    //    $(".nav_list").removeClass("f-show").addClass("f-hide");
    //    $(".layout_content_sidebar_header li").parents(".layout_content_sidebar").find(".nav_list").eq(ind).removeClass("f_hide").addClass("f-show");
    //})


    //日历右侧内容高度
    //$(".sidebarcon").css("height", (document.body.offsetHeight - 160).toString() + 'px');
    //window.onresize = function () {
    //    $(".sidebarcon").css("height", (document.body.offsetHeight - 160).toString() + 'px');
    //}

    $(".sidebarcon").mCustomScrollbar({
        scrollButtons: {
            enable: false
        },
        advanced: {
            updateOnContentResize: true
        }
    });

    $(".layout_content_main").mCustomScrollbar({
        scrollButtons: {
            enable: false
        },
        advanced: {
            updateOnContentResize: true
        }
    });
})